package com.zzyl.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.entity.NursingProject;
import com.zzyl.mapper.NursingProjectMapper;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author by 孙有泽
 * @Date 2024/11/28 22:39
 * @Description
 */
@Service
public class NursingProjectServiceImpl implements NursingProjectService {

    @Autowired
    private NursingProjectMapper nursingProjectMapper;


    /*
     * @author 孙有泽
     * @date 2024/12/4 21:35
     * @description 护理项目分页查询
     */

    @Override
    public PageResponse<NursingProjectVo> getByPage(String name, Integer pageNum, Integer pageSize, Integer status) {
        PageHelper.startPage(pageNum,pageSize);
        Page<NursingProjectVo> byPage = nursingProjectMapper.getByPage(name, status);
        return PageResponse.of(byPage,NursingProjectVo.class);
    }
    /*
     * @author 孙有泽
     * @date 2024/12/4 21:36
     * @description 护理项目添加
     */
    @Override
    public void add(NursingProjectDto nursingProjectDto) {
        NursingProject nursingProject=new NursingProject();
        BeanUtils.copyProperties(nursingProjectDto, nursingProject);
        nursingProjectMapper.insert(nursingProject);
    }
    /*
     * @author 孙有泽
     * @date 2024/12/5 21:16
     * @description 根基id查询护理项目
     */

    @Override
    public NursingProjectVo getById(Long id) {
        NursingProjectVo nursingProjectVo= nursingProjectMapper.getById(id);
        return  nursingProjectVo;
    }
    /*
     * @author 孙有泽
     * @date 2024/12/5 21:22
     * @description 更新护理项目
     */
    @Override
    public void update(NursingProjectDto nursingProjectDto) {
        NursingProject nursingProject = new NursingProject();
        BeanUtils.copyProperties(nursingProjectDto, nursingProject);
        nursingProjectMapper.updata(nursingProject);
    }
}
